package de.openkanban.client.util;

import de.openkanban.client.Main;
import de.openkanban.client.ui.board.BoardComponent;
import de.openkanban.client.ui.board.EnterBoardNameView;
import de.openkanban.client.ui.board.KanbanView;
import de.openkanban.shared.dto.BoardDto;

/**
 * The Main Panel of the Application. Used to handle cross dependencies between UI components.
 */
public abstract class RootPanel {

	public static Main main;

	public static BoardComponent boardComponent = new BoardComponent();

	/**
	 * Sets some UI parameters to enable and disable board edit mode
	 * @param isEditMode
	 */
	public static void activateBoardEditMode(boolean isEditMode) {
		if (isEditMode) {
			EnterBoardNameView enterBoardNameView = new EnterBoardNameView();

			if (main.getBoard().getWhiteBoardView().getBoardDto().getBoardId() != null) {
				enterBoardNameView.showCancelButton();
			} else {
				enterBoardNameView.hideCancelButton();
			}

			main.getBoard().getBoardHeaderHLayout().hide();
			main.getBoard().getWhiteBoardView().showEnterBoardNameView();
			main.getBoard().getNewKanbanButton().hide();
			main.getFooter().hideBoardContactTileGrid();
			main.getFooter().hideBoardHistoryListGrid();
			main.getAdminPanel().getNewBoardButton().hide();
		} else {
			main.getBoard().getWhiteBoardView().hideEnterBoardNameView();
			main.getFooter().showBoardContactTileGrid();
			main.getFooter().showBoardHistoryListGrid();
			main.getBoard().getCurrentBoardNameLabel().setContents(RootPanel.getCurrentBoardDto().getBoardName());
			main.getBoard().getBoardHeaderHLayout().show();
			main.getAdminPanel().getNewBoardButton().show();
		}
	}

	public static BoardDto getCurrentBoardDto() {
		return main.getBoard().getWhiteBoardView().getBoardDto();
	}

	public static void activateEditKanbanMode(boolean isEditMode) {
		main.getBoard().setKanbanEditMode(isEditMode);
	}

	public static void activateEditKanbanMode(boolean isEditMode, KanbanView kanbanView) {
		main.getBoard().setKanbanEditMode(isEditMode, kanbanView);
	}

}
